package cn.wolfcode.transfer.service.impl;

import cn.wolfcode.transfer.domain.Log;
import cn.wolfcode.transfer.mapper.LogMapper;
import cn.wolfcode.transfer.qo.QueryObject;
import cn.wolfcode.transfer.service.ILogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements ILogService {

    @Autowired
    private LogMapper logMapper;


    @Override
    public void save(Log log) {
        logMapper.insert(log);
    }

    @Override
    public void delete(Long id) {
        logMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(Log log) {
        logMapper.updateByPrimaryKey(log);
    }

    @Override
    public Log get(Long id) {
        return logMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Log> listAll() {
        return logMapper.selectAll();
    }

    @Override
    public PageInfo<Log> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize()); //对下一句sql进行自动分页
        List<Log> logs = logMapper.selectForList(qo); //里面不需要自己写limit
        return new PageInfo<Log>(logs);
    }
}
